package com.zbkj.common.request.order;

import com.zbkj.common.exception.CommonException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @Auther:
 * @Date: 2024/9/15 19:53
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "AdminOrderSaveRequest对象", description = "服务端-订单保存请求对象")
public class AdminOrderSaveRequest implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户手机号")
    @NotBlank(message = "用户手机号不能为空")
    private String userPhone;

    @ApiModelProperty("应付金额")
    @NotNull(message = "应付金额不能为空")
    private BigDecimal totalAmount;

    @ApiModelProperty("订单明细集合")
    @NotEmpty(message = "订单明细不能为空")
    List<OrderDetailSaveRequest> orderDetailList;

    @ApiModelProperty("转账凭证图片url集合")
    List<String> payVouchesList;

    @ApiModelProperty("备注")
    private String remark;

    public void paramCheck() {
        if(totalAmount.compareTo(BigDecimal.ZERO) <= 0) {
            throw new CommonException("订单应付金额必须大于0");
        }
    }
}
